Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Fix/72 #75

Merged
merged 4 commits into from
May 13, 2015
Merged

Fix/72 #75

merged 4 commits into from
May 13, 2015

Conversation

bobylito
Copy link
Contributor

@bobylito bobylito added this to the 2.0.3 milestone May 12, 2015
@@ -365,9 +365,16 @@ SearchParameters.prototype = {
* @return {SearchParameters}
*/
addFacetRefinement : function addFacetRefinement( facet, value ) {
if( this.isRefined( facet, value ) ) {
return this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it return a this.mutateMe(noop) instead ? So the return of addFacetRefinement is consistenly a new object ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case isRefined( facet, value ) returns true, it would mean that there would be no changes, so might as well avoid creating a new instance (there are thousands of case we create useless new objects, true :D, it's just continuous improvement here)

@Jerska
Copy link
Member

Jerska commented May 12, 2015

Except that, LGTM. 👍

@redox
Copy link
Contributor

redox commented May 12, 2015

👍 LGTM

if( idx > -1 ) {
m.facetsRefinements[ facet ].splice( idx, 1 );
if( m.facetsRefinements[ facet ].length === 0 ) {
delete m.facetsRefinements[ facet ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to delete the array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we remove the key from the object so when iterating with a for in we don't need to check for the content.

@vvo
Copy link
Contributor

vvo commented May 13, 2015

LGTM

@bobylito
Copy link
Contributor Author

Thanks for the comments :) Merging!

bobylito added a commit that referenced this pull request May 13, 2015
@bobylito bobylito merged commit 70dfff7 into master May 13, 2015
@bobylito bobylito deleted the fix/72 branch May 13, 2015 09:11
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants